magic
magic(size: number) : Mat
param size
- the number
representing the size of the square magic matrix (dimension-wise). If size = 4
, it'll generate a 4x4 "magic matrix".
returns: Mat
- a Mat
of dimenions size x size
, with the magic propeerties imbued making it a magic matrix.
This function creates a magic matrix given a number, the size of the matrix to make. A magic matrix is one where the rows, columns, and main diagonals sum up to the same values. The magic matrix is square. An example is given in the section below. Try it out for different sizes.